//
//  CCUICreator.m
//  DingDongZP
//
//  Created by Ray on 16/5/5.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

#import "CCUICreator.h"

@implementation UILabel (CCUICreator)

+ (instancetype)labelWithFrame:(CGRect)frame font:(UIFont *)font textColor:(UIColor *)color text:(NSString *)text
{
    UILabel *shortName = [[UILabel alloc] initWithFrame:frame];
    shortName.font = font;
    shortName.textColor = color;
    shortName.text = text;
    return shortName;
}

@end

@implementation UIButton (CCUICreator)


+ (instancetype)buttonWithFrame:(CGRect)frame title:(NSString *)title image:(UIImage *)image background:(UIImage *)bgimage target:(id)target selector:(SEL)sel {
    UIButton *btn = [[UIButton alloc] initWithFrame:frame];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setImage:image forState:UIControlStateNormal];
    [btn setBackgroundImage:bgimage forState:UIControlStateNormal];
    [btn addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    return btn;
}

+ (instancetype)buttonWithFrame:(CGRect)frame image:(UIImage *)img hilightedImage:(UIImage *)himage target:(id)target selector:(SEL)sel {
    UIButton *btn = [[UIButton alloc] initWithFrame:frame];
    [btn setImage:img forState:UIControlStateNormal];
    [btn setImage:himage forState:UIControlStateHighlighted];
    [btn addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    return btn;
}

+ (instancetype)buttonWithFrame:(CGRect)frame image:(UIImage *)img selectedImage:(UIImage *)simage target:(id)target selector:(SEL)sel {
    UIButton *btn = [[UIButton alloc] initWithFrame:frame];
    [btn setImage:img forState:UIControlStateNormal];
    [btn setImage:simage forState:UIControlStateSelected];
    [btn addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    return btn;
}

+ (instancetype)buttonWithFrame:(CGRect)frame target:(id)target selector:(SEL)sel {
    UIButton *btn = [[UIButton alloc] initWithFrame:frame];
    [btn addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    return btn;
}


@end
